<?php /* Smarty version Smarty 3.1.4, created on 2012-05-06 16:15:18
         compiled from ".\templates\promobanner\index.tpl" */ ?>
<?php /*%%SmartyHeaderCode:85714fa6a39640abd9-40579045%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '06b15079b1997327223cf03285f3fcaa28d7f744' => 
    array (
      0 => '.\\templates\\promobanner\\index.tpl',
      1 => 1334484556,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '85714fa6a39640abd9-40579045',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'title' => 0,
    'promobanner_arr' => 0,
    'promobanner_arrc' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty 3.1.4',
  'unifunc' => 'content_4fa6a3968ea2e',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_4fa6a3968ea2e')) {function content_4fa6a3968ea2e($_smarty_tpl) {?><script language="javascript" type="text/javascript" src="js/ajaxupload.3.5.js"></script>

<script type="text/javascript">
	$(function(){
		var btnUpload=$('#upload');
		var status=$('#status');
		new AjaxUpload(btnUpload, {
			action: 'controller.php?task=addpromobanner',
			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Only JPG, PNG or GIF files are allowed');
					return false;
				}
				status.text('Uploading...');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');
				//Add uploaded file to list
				if(response==="success"){
					loadPage("promobanner/index");
					$("#message_area").show();
					$("#message_area").html("<span class='success'>Banner has been successfully uploaded.</span>");
					$('<li></li>').appendTo('#files').html('<img src="../images/banners/thumbs/'+file+'" alt="" width="100" height="100" /><br />').addClass('success');
				} else{
					//$('<li></li>').appendTo('#files').text(file).addClass('error');
					loadPage("promobanner/index");
					$("#message_area").show();
					//$("#message_area").html("<span class='error'>Sorry. Banner is already uploaded. Please select another image.</span>");
					
				}
			}
		});
		
	});

	
</script>

<div id="page-heading">
	<h1><?php echo $_smarty_tpl->tpl_vars['title']->value;?>
</h1>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td width="15%" height="100" align="center" valign="top">		
			<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
          		<tr>
            		<th align="left" class="table-header-repeat">&nbsp;</th>
          		</tr>
          		<tr>
            		<td>
            			<div id="upload">Upload File</div>
            			<!--<div id="browsepromobanner" onclick="browseAll();"><span>Browse All<span></div>    -->
            		</td>
          		</tr>
      		</table>
      	</td>
      	<td width="2%">&nbsp;</td>	
        <td width="68%" valign="top" align="center">
        	<span id="status" ></span>		
			<ul id="files" ></ul>			
			<?php if (!empty($_smarty_tpl->tpl_vars['promobanner_arr']->value)){?> 
			<div id="showimages">
				<ul id="gal_files photos">
					<?php if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop=$_smarty_tpl->tpl_vars['promobanner_arr']->value) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop']-1;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
    $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
    if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0)
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
} else
    $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']):

            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1;
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
                 $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++):
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first']      = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1);
$_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last']       = ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']);
?>
                                    <li><a href="../images/promobanners/<?php echo $_smarty_tpl->tpl_vars['promobanner_arrc']->value;?>
"><img width="175" height="60" id="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['promobanner_id'];?>
" alt="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['url'];?>
" alt="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['filename'];?>
" src="../images/promobanner/thumbs/<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['filename'];?>
" alt="" width="100" height="100" /></a><br /><img src="images/icons/remove.png" class="cursor" onclick="delpromoimage(<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['promobanner_id'];?>
)" /></li>
                                    <h4><?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['url'];?>
</h4>
                                    <input onblur="updategalurl(this.id,this.value)" id="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['promobanner_id'];?>
" type="text" name="url" value="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['url'];?>
"  />
                                   <br>   <input <?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['newwindow'];?>
  onchange="updatenewwindow(this.value)" id="chk<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['promobanner_id'];?>
" type="checkbox" name="newwindow" value="<?php echo $_smarty_tpl->tpl_vars['promobanner_arr']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['promobanner_id'];?>
"  /> Open in new window
                                    <?php endfor; endif; ?>
				</ul>
			</div>
			<?php }else{ ?>
			<div id="showimages">Sorry. Currently promobanner is empty.</div>
			<?php }?>
        </td>		
	</tr>	
</table>

<script type="text/javascript">

function delpromoimage(promo_id)
{
	var msg = confirm("Are you sure you want to delete this image?")
	if (msg){
		$.ajax({
			type: "POST",
			url: 'controller.php?task=delpromoimage',
			data: ({promo_id: promo_id}),
	    	success: function(data, textStatus, XMLHttpRequest){
	    	   	if(data != '') {
                            alert("successfully deleted the image");
	    			$("#message_area").html(data);
	    			loadPage('promobanner/index');
	    	   	}
	    	},
	    	complete: function complete(XMLHttpRequest, textStatus){
	            //$("#loader_area").hide();
	        }
		});
	} else {
		return false;
	}
}

    function updategalurl(id,val){
          $("#loader_area").show();
		$("#loader_area").html('<img src="images/shared/loader.gif" /> loading...');

		$.ajax({
		type: "POST",
		url: 'controller.php?task=updatepromourl',
                data: ({promo_id: id,url:val}),
    	success: function(data, textStatus, XMLHttpRequest){
    	   	if(data != '') {
                       alert("successfully updated the link");
                        $("#message_area").show();
	    	   	$("#message_area").html(data);
                        loadPage('promobanner/index');
    	   	}
    	},
    	complete: function complete(XMLHttpRequest, textStatus){
            //$("#loader_area").hide();
        }
	});

}

    function updatenewwindow(val){
    //alert(val);
          $("#loader_area").show();
		$("#loader_area").html('<img src="images/shared/loader.gif" /> loading...');
                if($('#chk'+val).is(':checked')) {
                         var isnewwindow='checked';
                }
                else{
                      var isnewwindow='';
                }
        //  alert(isnewwindow);
		$.ajax({
		type: "POST",
		url: 'controller.php?task=updatepromonewwindow',
                data: ({promoid:val,isnewwindowval: isnewwindow}),
    	success: function(data, textStatus, XMLHttpRequest){
    	   	if(data != '') {
                       alert("successfully updated the target ");
                        $("#message_area").show();
	    	   	$("#message_area").html(data);
                        loadPage('promobanner/index');
    	   	}
    	},
    	complete: function complete(XMLHttpRequest, textStatus){
            //$("#loader_area").hide();
        }
	});

}


</script><?php }} ?>